package com.yanqu.road.server.cmd.wingroom.shareevent;

import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.wingroom.WingRoomMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @author ：zfr
 * @date ：2022/2/11 14:41
 */
@Cmd(code = GameProtocol.S_WING_ROOM_SHARE_EVENT, desc = "厢房分享事件")
public class ShareEventCmd extends AbstractCommand {
    private int shareType;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomProto.ShareEventReqMsg reqMsg = WingRoomProto.ShareEventReqMsg.parseFrom(packet.getBytes());
        shareType = reqMsg.getShareType();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = WingRoomMgr.shareEvent(player, shareType);
    }

    @Override
    public void sendData(GamePlayer player) {
        WingRoomProto.ShareEventRespMsg.Builder respMsg = WingRoomProto.ShareEventRespMsg.newBuilder();
        respMsg.setRet(ret);
        player.sendPacket(Protocol.U_WING_ROOM_SHARE_EVENT, respMsg);
    }
}
